package com.roncoo.education.course.service.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.roncoo.education.course.service.dao.CoursePeriodDao;
import com.roncoo.education.course.service.dao.impl.mapper.CoursePeriodMemoryMapper;
import com.roncoo.education.course.service.dao.impl.mapper.entity.CoursePeriodMemory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CoursePeriodDaoImpl implements CoursePeriodDao {

    @Autowired
    private CoursePeriodMemoryMapper coursePeriodMemoryMapper;

    @Override
    public CoursePeriodMemory getByVideoNoAndUserNo(Long videoNo, Long userNo) {
        QueryWrapper<CoursePeriodMemory> eq = new QueryWrapper<CoursePeriodMemory>().eq("video_no", videoNo).eq("user_no", userNo);
        return coursePeriodMemoryMapper.selectOne(eq);
    }

    @Override
    public int updateById(CoursePeriodMemory coursePeriodMemory) {
        return coursePeriodMemoryMapper.updateById(coursePeriodMemory);
    }

    public int save(CoursePeriodMemory coursePeriodMemory){
        return coursePeriodMemoryMapper.insert(coursePeriodMemory);
    }
}
